import moment from 'moment';

//echart配置文件
function echartOption(xAxisData, seriesData){
    const option = {
        grid: {
            top: '20%',
            bottom: '20%',
            left: '10%',
            right: '5%'
        },
        tooltip: {
            textStyle: {
                color: '#FFFFFF',
                fontSize: 10,
                fontWeight: 500
            },
            formatter: function(params){
                return `<div style="text-align:center;">${params.name} ${params.seriesName}<br/>${params.value}mm</div>`;
            }
        },
        legend: {
            type: 'scroll',
            right: 10,
            itemWidth: 15,
            itemHeight: 8,
            itemGap: 8,
            borderRadius: 8,
            textStyle: {  
                color: '#12202D',
                fontWeight: 500,
                fontSize: 10
            }
        },
        xAxis: {
            axisLine: {
                lineStyle: {
                    color: '#B2C6E0'
                }
            },
            axisLabel: {
                color: '#12202D',
                fontWeight: 400,
                fontSize: 10,
                formatter: function(value, index){
                    return moment(value, 'YYYY-MM-DD').format('YYYY')+'年';
                }
            },
            axisTick: {
                show: false
            },
            data: xAxisData
        },
        yAxis: {
            name: 'mm',
            nameTextStyle: {
                color: '#12202D',
                fontWeight: 400,
                fontSize: 10,
                verticalAlign: 'middle',
                align: 'right'
            },
            axisLine: {
                lineStyle: {
                    width: 0
                }
            },
            axisLabel: {
                color: '#12202D',
                fontWeight: 400,
                fontSize: 10
            },
            axisTick: {
                show: false
            },
            // minInterval: 1,
            // splitNumber: 5,
            // min: 0,
            // max: 4,
            splitLine: {
                lineStyle: {
                    color: '#B2C6E0'
                }
            }
        },
        series: seriesData
    };
    
    return option;
}

export default echartOption;